package com.zyl.Ecs.realtime.task;

import com.zyl.Ecs.common.utils.CUtil;
import com.zyl.Ecs.realtime.service.TableService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @version v1.0
 * @ProjectName: Ecs
 * @Package: com.zyl.Ecs.realtime.task
 * @ClassName: StartUpRunner
 * @Description TODO
 * @Author 翟玉龙
 * @Date 2024/12/6-13:31
 */
@Component
@RequiredArgsConstructor
public class StartUpRunner implements ApplicationRunner {

    private final TableService tableService;

    @Override
    public void run(ApplicationArguments args) {
        new Thread(new CreateTableThread()).start();
    }

    /**
     * 创建动态表格线程
     */
    class CreateTableThread implements Runnable {
        @Override
        public void run() {
            CUtil.logInfo("====================开始建表====================");
            tableService.createCurrentMonthTable();
            CUtil.logInfo("====================建表结束====================");
        }
    }
}
